using Unity.Burst;
using static DA.AnimGraph.PerkLink;

namespace DA.AnimGraph {

    [BurstCompile]
    public unsafe struct PerkVirtualTable {

        // Evaluate
        //internal delegate void EvaluateDelegate(in void* perk, in TimeState* t, bool o, in EvaluateContext e, in GraphContext g, ref UpstreamData u, ref ScopeContext s);
        internal void* EvaluateFunctionPtr;
        internal EvaluateDelegate EvaluateFunction {
            set { EvaluateFunctionPtr = BurstCompiler.CompileFunctionPointer(value).Value.ToPointer(); }
        }
        internal delegate* unmanaged[Cdecl]<in void*, in TimeState*, bool, in EvaluateContext, in GraphContext, ref UpstreamData, ref ScopeContext, void> EvaluateFunctionCall {
            get => (delegate* unmanaged[Cdecl]<in void*, in TimeState*, bool, in EvaluateContext, in GraphContext, ref UpstreamData, ref ScopeContext, void>)EvaluateFunctionPtr;
        }

        // OnExit
        //internal delegate void OnExitDelegate(in void* perk, ref UpstreamData u);
        internal void* OnExitFunctionPtr;
        internal OnExitDelegate OnExitFunction {
            set { OnExitFunctionPtr = BurstCompiler.CompileFunctionPointer(value).Value.ToPointer(); }
        }
        internal delegate* unmanaged[Cdecl]<in void*, in TimeState*, ref UpstreamData, void> OnExitFunctionCall {
            get => (delegate* unmanaged[Cdecl]<in void*, in TimeState*, ref UpstreamData, void>)OnExitFunctionPtr;
        }

        // PostEvaluate
        //internal delegate void PostEvaluateDelegate(in void* perk, in TimeState* t, in EvaluateContext e, in GraphContext g, ref UpstreamData u, ref PostScopeContext p);
        internal void* PostEvaluateFunctionPtr;
        internal PostEvaluateDelegate PostEvaluateFunction {
            set { PostEvaluateFunctionPtr = BurstCompiler.CompileFunctionPointer(value).Value.ToPointer(); }
        }
        internal delegate* unmanaged[Cdecl]<in void*, in TimeState*, in EvaluateContext, in GraphContext, ref UpstreamData, ref PostScopeContext, void> PostEvaluateFunctionCall {
            get => (delegate* unmanaged[Cdecl]<in void*, in TimeState*, in EvaluateContext, in GraphContext, ref UpstreamData, ref PostScopeContext, void>)PostEvaluateFunctionPtr;
        }
    }
}